<%--
  Created by IntelliJ IDEA.
  User: 宇
  Date: 2023/8/14
  Time: 19:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false"  %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="path" value="${pageContext.request.contextPath }"/>
<html>
<head>
    <title>电影院添加页面</title>
    <script src="${path}/js/jquery-3.6.4.js"></script>
    <link href="${path}/css/cinemaAdd.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="box1">
    <h1>电影院添加</h1>
    <form method="post"  id="box2" enctype="multipart/form-data" action="${path}/CinemaServlet?prom=cinCount" onsubmit="return checkInfo()">
        <table border="1">
            <tr>
                <td><img id="moviePirture" name="cinema_img" src="${path}/images/cinemaPicture/tjtb.jpg"/></td>
                <td>
                    <input type="button" value="选择头像" id="xztx">
                    <input id="file" type="file" multiple="multiple" name="cinema_img"/>
                </td>
            </tr>
            <tr>
                <td class="a1">影院名称</td>
                <td class="a2"><input type="text" id="cinema_name" name="cinema_name"><span></span></td>
            </tr>
            <tr>
                <td class="a1">影院地址</td>
                <td class="a2"><input type="text" id="cinema_address" name="cinema_address" ><span></span></td>
            </tr>
            <tr>
                <td class="a1">影院号码</td>
                <td class="a2"><input type="text" id="cinema_phone" name="cinema_phone" ><span></span></td>
            </tr>
            <tr>
                <td class="a1">影院评分</td>
                <td class="a2"><input type="text" id="cinema_score" name="cinema_score"><span></span></td>
            </tr>
            <tr>
                <td class="a1">添加时间</td>
                <td class="a2"><input type="text" id="cinema_time" name="cinema_time"><span></span></td>
            </tr>
            <input type="submit" class="a3">
            <input type="button" value="返回" onclick="javascript:window.location='cinemaslist.jsp'" class="a3">
        </table>
    </form>

</div>
<script>
    $("#file").change(function(){
        var url=document.getElementById('file').files[0].name;
        $("#moviePirture").attr("src","${path}/images/cinemaPicture/"+url);
        //获取文件全部路径
        var urlPath=document.getElementById('file').value;
    })
    function checkInfo(){
        let data_format=/^((\d{2}(([02468][048])|([13579][26]))[-\/\s]?((((0?[13578])|(1[02]))[-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[-\/\s]?((((0?[13578])|(1[02]))[-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s((([0-1][0-9])|(2?[0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$/
        let imgUrl=$("#file").val();
        let cinema_name=$("#cinema_name").val();
        let cinema_address=$("#cinema_address").val();
        let cinema_phone=$("#cinema_phone").val();
        let cinema_score=$("#cinema_score").val();
        let cinema_time=$("#cinema_time").val();
        if (imgUrl==""||imgUrl==null){
            alert("影院头像不能为空!");
            return false;
        }
        if (cinema_name==""||cinema_name==null){
            alert("影院名称不能为空!");
            return false;
        }
        if (cinema_address==""||cinema_address==null){
            alert("影院地址不能为空!");
            return false;
        }
        if (cinema_phone==""||cinema_phone==null){
            alert("影院号码不能为空!");
            return false;
        }
        if (cinema_score==""||cinema_score==null){
            alert("影院评分不能为空!");
            return false;
        }
        if (cinema_time==""||cinema_time==null){
            alert("影院时间不能为空!");
            return false;
        }
        if(!data_format.test(cinema_time)){
            alert("影院时间格式不正确！请重新输入");
            return false;
        }
        return true;
    }
</script>
</body>
</html>
